<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/common/jsp/taglibs-nojs-nocss.jsp"%>
<%@include file="/common/jsp/cssAndScript.jsp"%>
<%@ page isELIgnored="false" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<base href="<%=basePath%>"/>
<%@include file="/pages/head.jsp"%>
<div id="main_container">
  <div id="container_border">
        <div class="window_1">
        	<div id="assistFee_div">
            	<h3 class="priceRulelist_title_pic_2">出差考勤管理</h3>
            		<table border="0" cellspacing="0" cellpadding="0" width="100%">
						<tr>
							<td>
								<si:role url="/timing/getAllClock">
									<a class="btn_grid_box btn_search_file" style="height:28px;margin-left:4px;" href="javascript:void(0);">
									请选择人员
											<s:select id="userId" onchange="changeDatee();" list="users" name="userId" headerKey="" headerValue="请选择" value="userId" listKey="id" listValue="cname" theme="simple" cssClass="required"/>
									</a>
								</si:role>
								<a class="btn_grid_box btn_search_file" style="height:28px;margin-left:4px;" href="javascript:void(0);">
								请选择时间<s:select id="year" list="#{'2011':'2011','2012':'2012','2013':'2013','2014':'2014','2015':'2015','2016':'2016','2017':'2017','2018':'2018'}" name="year" headerKey="" headerValue="请选择" value="year" theme="simple" cssClass="required"/>年
										<s:select id="month" list="#{'1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'8','9':'9','10':'10','11':'11','12':'12'}" name="month" onchange="changeDatee();" headerKey="" headerValue="请选择" value="month" theme="simple" cssClass="required"/>月</a>
							</td>
						</tr>
					</table>
        	</div>
        </div>
    <div class="window_bottom">
		<div id="pricerulemanage" style="height:450px;">         
            <table width="100%" border="0" cellpadding="0"  cellspacing="0" class="gridview"  id="pricerule_table">
                <thead>
              <tr class="title">
                    <td style="width: 150px;">序号</td>
                    <td >签到人</td>
                    <td >签到日期</td>
                    <td >签到时间</td>
                    <td >签到类型</td>
                    <td >签到结果</td>
                </tr>
                </thead>
                <tbody class="mytbody">
                	<s:if test="listTimingVo.size()==0">
                		<tr>
                			<td colspan="7" align="center">无记录</td>
                		</tr>
                	</s:if><s:else>
		                <s:iterator value="listTimingVo" status="stat">
			                <tr>
			                   <td><s:property value="#stat.count"/></td>
			                    <td ><s:property value="user.cname"/></td>
			                    <td ><s:property value="thisDate" /></td>
			                    <td ><s:property value="clockTime" /></td>
			                    <td >
				                    <s:if test="type=='am'">
				                    	上班
				                    </s:if>
				                    <s:else>
				                    	下班
				                    </s:else>
			                    </td>
			                    <td>
			                    	<s:if test="flag==-1">
			                    		<font color="red">迟到</font>
			                    	</s:if>
			                    	<s:if test="flag==-2">
			                    		<font color="red">早退</font>
			                    	</s:if>
			                    	<s:if test="flag==-3">
			                    		<font color="red">旷工</font>
			                    	</s:if>
			                    	<s:if test="flag==0">
			                    		正常
			                    	</s:if>
			                    </td>
			                </tr>
		                </s:iterator>
                	</s:else>
                </tbody>
           </table>
        </div> 
    </div>
  </div>
</div>
<script type="text/javascript">
	function changeDatee(){
		var year = document.getElementById('year').value;
		var month = document.getElementById('month').value;
		var _url = "";
		if(exist('userId')){
			var userId = document.getElementById('userId').value;
			_url = 'timing/getAllClockByUid?year='+year+'&month='+month+'&userId='+userId;
		}else{
			_url = 'timing/getAllClockByUid?year='+year+'&month='+month;
		}
		loadContentLink('<%=basePath %>'+_url);
	}
	
    function onSubmitClock(id){
        if(window.confirm("您确定要进行打卡操作吗？")){
        	var _url = 'timing/clock?timingVo.id='+id;
    		$.ajax( {
    			url : _url,
    			type : 'GET',
    			success : function(result){
    				// 通过返回的json信息来处理
    				// 通过javascript对象把返回的结果转为javascript对象
    				var jsonMsgObj=new JsonMsgObj(result);
    				// 通过getMessage()得到返回的异常信息,此异常信息为json格式
    				var  msg=jsonMsgObj.getMessage();
    			    var codeId=jsonMsgObj.getCodeid();
    				var isOk=jsonMsgObj.getIsok();
    				// 判断是否删除成功了，如果刷新table的区域
    				if( isOk ){
    					// 隐藏窗口
    					aerouiAlert( msg );
    					alert('ff');
    					loadContentLink('<%=basePath %>timing/gotoClock');
    				// 如果没有删除成功,那就alert出异常的信息
    				}else{
    					aerouiAlert( msg );
    				}
    			}
    		} );
        }
    }
    function exist(id){
        var s=document.getElementById(id);
        if(s){
            return true;
        }else{
            return false;
        }
    }
</script>